package com.hluobo.gnnulibrary.ui;

import com.hluobo.gnnulibrary.R;
import com.hluobo.gnnulibrary.adapter.AnnouncementListAdapter;
import com.hluobo.gnnulibrary.adapter.ImageSliderAdapter;
import com.hluobo.gnnulibrary.view.ImageSliderView;

import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ListView;

public class HomeFragment extends Fragment {

	private static final String TAG = "com.hluobo.gnnulibrary";
	
	private View view;
	
	private ListView lv_announcement;
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		
		lv_announcement = (ListView) view.findViewById(R.id.home_lv_announcements);
//		LinearLayout v = new LinearLayout(getActivity());
//		LayoutParams params = new LayoutParams(80, 80);
//		v.setLayoutParams(params);
//		v.setBackgroundDrawable(getResources().getDrawable(R.drawable.login_box));
//		lv_announcement.addHeaderView(v);
		View v = View.inflate(getActivity(), R.layout.listitem_home_header, null);
//		View view = v.findViewById(R.id.sfdf);
//		Log.e(TAG, view.getTag().toString());
		
		ImageSliderView is = (ImageSliderView) v.findViewById(R.id.home_imageslider);
		is.setAdapter(new ImageSliderAdapter(getActivity()));
		
		lv_announcement.addHeaderView(v);
		lv_announcement.setDivider(null);
		lv_announcement.setAdapter(new AnnouncementListAdapter(getActivity()));
		
	}



	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		Log.i(TAG, "Fragment onCreateView");
		view = inflater.inflate(R.layout.fragment_home, container, false);
		return view;

	}

}
